package com.suifeng.card.controller;

import com.suifeng.card.entity.UserRolesRole;
import com.suifeng.card.service.UserRolesRoleService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * (UserRolesRole)表控制层
 *
 */
@RestController
@RequestMapping("userRolesRole")
public class UserRolesRoleController {
    /**
     * 服务对象
     */
    @Resource
    private UserRolesRoleService userRolesRoleService;


    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<UserRolesRole> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.userRolesRoleService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param userRolesRole 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<UserRolesRole> add(UserRolesRole userRolesRole) {
        return ResponseEntity.ok(this.userRolesRoleService.insert(userRolesRole));
    }

    /**
     * 编辑数据
     *
     * @param userRolesRole 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<UserRolesRole> edit(UserRolesRole userRolesRole) {
        return ResponseEntity.ok(this.userRolesRoleService.update(userRolesRole));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.userRolesRoleService.deleteById(id));
    }

}

